package com.acme.bankapp.client;

import java.io.*;
import java.util.ArrayList;

/**
 * Created by Java Student on 11/19/2014.
 */
public class BankClient {

    public static void main(String... args) {
        try {
            BankClientProxy bankClientProxy = new BankClientProxy(new BankClientTransport());
            BufferedReader kbdReader = new BufferedReader(new InputStreamReader(System.in));
            while(true) {
                String command = kbdReader.readLine();
                ArrayList<String> result = bankClientProxy.sendCommand(command);
                if (result.size() != 0) {
                    for (String line : result) {
                        System.out.println(line);
                    }
                } else {
                    System.out.println("Session ended. Closing connection.");
                    bankClientProxy.getBankClientTransport().getSocket().close();
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
